<template>
	<view>
		<view class="search-box">
			<u--input placeholder="搜索" v-model="queryParams.cname" @confirm="search">
				<u-icon name="search" slot="suffix" color="#2979ff" size="28" @click="search"></u-icon>
			</u--input>
		</view>
		<mescroll-body @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
			<view class="item_list">
				<CustomerInfo v-for="item in dataList" :data="item" :checkInId.sync="item.checkInId">
				</CustomerInfo>

			</view>

		</mescroll-body>


	</view>
</template>

<script>
	import CustomerInfo from './CustomerInfo.vue'
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import {
		getCustomerList,
		getGoodStartCustomerlist
	} from '@/common/api/customer.js'

	import {
		getBadDistributionMap
	} from '@/common/api/performingLoan.js'
	export default {
		mixins: [MescrollMixin],
		components: {
			CustomerInfo
		},
		props: {
			hasGoodStart: { //1表示包含开门红数据
				type: String,
				default: null
			},
			type: { //1表示存款客户，2表示贷款客户，4表示开门红，5表示不良客户
				type: String,
				required: true,
				default: '1'
			}

		},

		data() {
			return {
				downOption: {
					offset: 80,

				},
				upOption: {
					page: {
						size: 10
					},
					empty: {
						tip: '暂无相关数据'
					}
				},
				dataList: [],
				queryParams: {
					cname: '',
					pageNum: 1,
					pageSize: 10
				}
			}
		},

		methods: {
			search() {
				this.canReset && this.mescroll.scrollTo(0, 0)
				this.canReset && this.mescroll.resetUpScroll()

				this.canReset = true
			},
			async upCallback(page) {
				this.queryParams.pageNum = page.num;
				this.queryParams.pageSize = page.size;
				if (this.queryParams.pageNum == 1) {
					this.dataList = []
				}
				var res = null;
				if (this.type == 'goodStart') {
					res = await getGoodStartCustomerlist({
						...this.queryParams,
						hasLonLat: '1'
					})
				} else {
					res = await getCustomerList({
						...this.queryParams,
						hasLonLat: '1',
						hasGoodStart: this.hasGoodStart,
						yewuSourceStr: this.type
					})
				}


				this.dataList = this.dataList.concat(res.rows);
				this.mescroll.endBySize(this.dataList.length, res.total);
			}
		}
	}
</script>

<style scoped lang="scss">
	.search-box {
		text-align: center;
		padding: 30rpx 70rpx 10rpx;

		::v-deep .u-input {
			border-radius: 10rpx !important;
		}
	}

	.item_list {
		padding: 0 30rpx 30rpx;

		.item-box {
			margin-top: 20rpx;
			// border: 1px solid #ccc;
			overflow: hidden;
			padding: 25rpx 45rpx;
			box-shadow: 0 2px 4px 0 rgba(0, 0, 0, .12), 0 0 6px 0 rgba(0, 0, 0, .04);
			box-shadow: 3px 3px 13px 0 rgba(0, 0, 0, 0.12), -3px -3px 13px 0 rgba(0, 0, 0, 0.12);
			box-shadow: 3px 3px 8px 0 rgba(0, 0, 0, 0.12), -3px 3px 8px 0 rgba(0, 0, 0, 0.12);

			.item {
				overflow: hidden;


				.l {
					float: left;
					width: 80%;

					.title {
						font-size: 30rpx;
						font-weight: 600;
					}

					.adress {
						color: #888888;
						font-size: 25rpx;
						margin: 10rpx 0;
					}
				}

				.r {
					float: right;
					position: relative;
					with: 20%;
					color: #888888;
					padding-top: 25rpx;
					font-size: 25rpx;
				}
			}

			.bnts {
				text-align: center;
				font-size: 18rpx;
				margin-top: 20rpx;

				text {
					padding: 8rpx 24rpx;
					margin: 10rpx 30rpx;
				}

				.checkIn {
					background-color: #92C1F7;
					color: #3D8DE7;
					border-radius: 16rpx;
				}

				.other {
					background-color: #FAE49D;
					color: #FFC300;
					border-radius: 16rpx;
				}
			}


		}
	}
</style>